<template>
	<view class="user pageBg">
		<view :style="{height: getNavBarHeight() + 'px'}"></view>
		<view class="userInfo">
			<view class="avatar">
				<image mode="aspectFill" class="ipc" src="/static/images/xxmLogo.png"></image>
			</view>
			<view class="ip">{{userInfo.IP}}</view>
			<view class="address">来自: {{userInfo.address?.city || userInfo.address?.province}}</view>
		</view>
		<view class="section">
			<view class="list">
				<view @click="onToClassList('download')">
					<user-com :count="userInfo.downloadSize"></user-com>
				</view>
				<view @click="onToClassList('score')">
					<user-com :icon="'star-filled'" :text="'我的评分'" :count="userInfo.scoreSize" ></user-com>
				</view>
				<user-com :isShow="true" :icon="'chatboxes-filled'" :text="'联系客服'"></user-com>
			</view>
		</view>
		
		<view class="section">
			<view class="list">
				<user-com :icon="'notification-filled'" :text="'订阅更新'"></user-com>
				<user-com :icon="'flag-filled'" :text="'常见问题'"></user-com>
				<!-- <view class="row" v-for="item in 2" :key="item">
					<view class="left">
						<uni-icons color="#28b389" type="download-filled" size="20"></uni-icons>
						<view class="text">我的下载</view>
					</view>
					<view class="right">
						<view class="count">10</view>
						<uni-icons type="right" size="15" color="#aaa"></uni-icons>
					</view>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script setup>
	import userCom from './components/userCom.vue';
	import {getNavBarHeight} from '@/utils/system.js'
	import {userInfoApi} from '@/api/apis.js'
	import { ref } from 'vue';
	
	uni.showLoading({
		title:"正在加载..."
	})
	//获取个人信息
	const userInfo = ref({})
	const getUserInfoApi = async ()=>{
		const res = await userInfoApi()
		userInfo.value = res
		uni.hideLoading()
	}
	
	getUserInfoApi()
	
	const onToClassList = (type) => {
		let name = ''
		if(type == 'download'){
			name = '我的下载'
		}else if(type == 'score'){
			name = '我的评分'
		}
		uni.navigateTo({
			url:"/pages/classList/classList?type="+type+"&name="+name
		})
	}
</script>

<style lang="scss" scoped>
.user{
	.userInfo{
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		padding: 50rpx 0;
		.avatar{
			width: 160rpx;
			height: 160rpx;
			border-radius: 50%;
			overflow: hidden;
			.ipc{
				width: 100%;
				height: 100%;
			}
		}
		.ip{
			font-size: 44rpx;
			color: #333;
			padding: 20rpx 0 5rpx;
		}
		.address{
			font-size: 28rpx;
			color: #aaa;
		}
	}
	.section{
		box-shadow: 0 0 30rpx rgba(0, 0, 0, 0.05);
		border: 1px solid #eee;
		border-radius: 10rpx;
		margin: 50rpx 30rpx;
	/*	.list{
			.row{
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 0 30rpx;
				border-bottom: 1px solid #eee;
				height: 100rpx;
				&:last-child{
					border-bottom: 0;
				}
				.left{
					display: flex;
					align-items: center;
					.text{
						padding-left: 20rpx;
						color: #666;
					}
				}
				.right{
					display: flex;
					align-items: center;
					.count{
						font-size: 28rpx;
						color: #aaa;
					}
				}
			}
		}
		*/
	}

}
</style>
